Skip to content

Conversation

@javier-godoy
Copy link
Member

@javier-godoy javier-godoy commented Feb 7, 2026

Log the resolved path of dynamic-theme.properties to identify and troubleshoot classpath conflicts caused by downstream dependencies.

Summary by CodeRabbit

  • New Features
    • Dynamic theme loading now supports multiple theme sources simultaneously.
    • Enhanced diagnostic logging to track theme application and sources.

@coderabbitai
Copy link

coderabbitai bot commented Feb 7, 2026

Walkthrough

DynamicThemeInitializer is updated to discover and apply themes from multiple META-INF/dynamic-theme.properties resources via the class loader, replacing single-resource loading. Helper methods for URL parsing and theme reading are added alongside logging to track theme application sources.

Changes

Cohort / File(s) Summary
Dynamic Theme Initialization Enhancement
src/main/java/com/flowingcode/vaadin/addons/demo/DynamicThemeInitializer.java
Refactored to iterate over multiple META-INF/dynamic-theme.properties resources instead of loading a single resource. Added helper methods readTheme(URL) for loading/parsing themes and getSourceName(URL) for extracting readable source identifiers from JAR/file URLs. Introduced logging to record theme application and source details. Added PROPERTIES_PATH constant and Logger field.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • paodb
  • mlopezFC
🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately reflects the main objective: adding logging to the dynamic-theme initialization process to help troubleshoot classpath conflicts.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch log-dynamic-theme-initializer

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 7, 2026

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In
`@src/main/java/com/flowingcode/vaadin/addons/demo/DynamicThemeInitializer.java`:
- Around line 50-57: The readTheme method currently returns empty silently when
the "theme" property is missing or invalid; update readTheme to (1) after
loading props check if props.getProperty("theme") is null or blank and log a
warning including the URL to indicate a misconfigured dynamic-theme.properties,
and (2) when mapping to DynamicTheme via DynamicTheme.valueOf, catch
IllegalArgumentException, log an error mentioning the invalid value and the URL,
and return Optional.empty; use the class logger (e.g., LOGGER or logger) for
these messages and keep the method signature and stream handling as-is.

Comment on lines +50 to +57
private Optional<DynamicTheme> readTheme(URL url) throws IOException {
try (InputStream in = url.openStream()) {
Properties props = new Properties();
props.load(in);
String themeName = props.getProperty("theme");
return Optional.ofNullable(themeName).map(String::trim).map(DynamicTheme::valueOf);
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Silent skip when theme property is missing from a discovered file.

If a dynamic-theme.properties file is found but doesn't contain the theme key (e.g., typo like themes=LUMO), readTheme returns an empty Optional and nothing is logged. Given that this class now explicitly scans for these files, a missing property is likely a configuration error and should at least be logged as a warning.

Proposed fix
   private Optional<DynamicTheme> readTheme(URL url) throws IOException {
     try (InputStream in = url.openStream()) {
       Properties props = new Properties();
       props.load(in);
       String themeName = props.getProperty("theme");
+      if (themeName == null || themeName.trim().isEmpty()) {
+        logger.warn("No 'theme' property found in {}", url);
+        return Optional.empty();
+      }
-      return Optional.ofNullable(themeName).map(String::trim).map(DynamicTheme::valueOf);
+      return Optional.of(DynamicTheme.valueOf(themeName.trim()));
     }
   }
🤖 Prompt for AI Agents
In
`@src/main/java/com/flowingcode/vaadin/addons/demo/DynamicThemeInitializer.java`
around lines 50 - 57, The readTheme method currently returns empty silently when
the "theme" property is missing or invalid; update readTheme to (1) after
loading props check if props.getProperty("theme") is null or blank and log a
warning including the URL to indicate a misconfigured dynamic-theme.properties,
and (2) when mapping to DynamicTheme via DynamicTheme.valueOf, catch
IllegalArgumentException, log an error mentioning the invalid value and the URL,
and return Optional.empty; use the class logger (e.g., LOGGER or logger) for
these messages and keep the method signature and stream handling as-is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: To Do

Development

Successfully merging this pull request may close these issues.

1 participant